﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Main.aspx.cs" Inherits="Score_School_ForManage_Main" %>

<%@ Register Src="../../../Custom/SchoolYear.ascx" TagName="SchoolYear" TagPrefix="uc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
    <link href="../../Common/css/main.css" rel="stylesheet" type="text/css" /> 

    <script type="text/javascript" src="../../Common/Js/jquery.js"></script>

    <script type="text/javascript" src="../../Common/Js/common.js"></script>

    <script type="text/javascript" src="../../Common/Js/msg.js"></script>

    <script type="text/javascript" src="../../Common/Js/jsUtil.js"></script>

    <script type="text/javascript">
    var temptypeid = 0;
    function OnView()
    {
        document.getElementById("btnBind").click();
    }
    
    function OnShowInput(y,t,et,g)
    {
        document.getElementById("parfrm").src="ShowClassStatus.aspx?year="+y+"&term="+t+"&examtype="+et+"&grade="+g;
        ShowPopForm("upInputPop", "upInputPopTitle","分数段分析设置")   ; 
    }
    function MyClosePopForm()
    {
        document.getElementById("parfrm").src="about:blank";
        ClosePopForm('upInputPop');       
    }
    function OnTermChange(y,t)
    {

        document.getElementById("schoolyearTxt").value=y;
        document.getElementById("termTxt").value=t;
        OnView();
    }
    function ShowExamInfo(typeid)
    {
        PageMethods.GetExamAreaInfo(document.getElementById("schoolyearTxt").value,document.getElementById("termTxt").value,typeid,document.getElementById("gradeTxt").value,function(succ){
            temptypeid = typeid;
            document.getElementById("areainfo").innerHTML=succ;
            ShowPopForm("popTable", "formTitle","区平均分设置")   ; 
        },function(err){
            showMassgeBox("提示",err._message,1,null);
        });
    }
    
        ///关闭
    function CloseMask(formId)
    { 
       
        ClosePopForm(formId,true);
        hideMask(); 
        
    }
    function OnSave(formId)
    {
        var arr = document.getElementById("areainfo").getElementsByTagName("input");
        var ids = new Array();
        var score = new Array();
        var index = 0;
        for(var i=0;i<arr.length;i++)
        {
            if(arr[i].type=="text" && arr[i].disabled==false)
            {
                var temp = parseFloat(arr[i].value);
                if(!isNaN(temp))
                {
                    ids[index] = arr[i].subjid;
                    score[index] = arr[i].value;
                    index++;
                }
                
            }
        }
        PageMethods.SaveAreaInfo(document.getElementById("schoolyearTxt").value,
            document.getElementById("termTxt").value,temptypeid,
            document.getElementById("gradeTxt").value,ids,score,function(succ){
            
            CloseMask('popTable');
            OnView();
            
        },function(err){
            showMassgeBox("提示",err._message,1,null);
        });
        ClosePopForm(formId,true);
        hideMask(); 
    }
    function OnClickCB(id)
    {
        var ischeck = document.getElementById("c"+id).checked;
        if(ischeck)
        {
            document.getElementById("textc"+id).disabled=false;
            
        }
        else
        {
            document.getElementById("textc"+id).value = '';
            document.getElementById("textc"+id).oldvalue = '';
            document.getElementById("textc"+id).disabled=true;
            
        }
    }
    function optionSettingScore(obj)
    {
        var score = parseFloat(obj.value);
        
        if(!isNaN(score))
        {
            obj.oldvalue= obj.value;
        }
        else
        {
            obj.value= obj.oldvalue;
        }
    }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
        </asp:ScriptManager>
        <div class="mainWarp" style="height: 88%; overflow: auto; border-top: #9be0f0 1px solid;">
            <div class="pageBody">
                <uc1:SchoolYear ID="SchoolYear1" runat="server" />
                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                     <ContentTemplate>
                        <asp:Repeater ID="Repeater1" runat="server">
                            <HeaderTemplate>
                                <div style="overflow-y:auto;overflow-x:none;height:98%;">
                                <table id="examInfo" border="0" cellpadding="0" cellspacing="1" class="useList" style=" width:80%;">
                                <tr class="tableTitle">
                                    <th width="20%" style="text-align:left;padding-left:5px;" >考试名</th>
                                    <th width="20%" style="text-align:center;padding-left:5px;" >成绩录入</th>
                                    <th width="20%" style="text-align:center;padding-left:5px;" >B值计算</th>
                                    <th width="40%" style="text-align:left;padding-left:5px;" >B值</th>
                                </tr>
                            </HeaderTemplate>
                            <ItemTemplate>
                                <tr class="tableTitle">
                                    <td style="text-align:left;padding-left:5px;"><%# GetExamName((int)Eval("ExamType"))%></td>
                                    <td width="20%" style="text-align:center;padding-left:5px;"><a href="#" onclick="OnShowInput(<%# Eval("SchoolYear")%>,<%# Eval("Term")%>,<%# Eval("ExamType")%>,<%# Eval("Grade")%>)">录入成绩</a></td>
                                    <td width="20%" style="text-align:center;padding-left:5px;"><%# canDomanage ? ("<a href='#' onclick='ShowExamInfo(" + Eval("ExamType").ToString() + ")'>重新计算</a>") : ""%></td>
                                    <td width="40%" style="text-align:left;padding-left:5px;"><%# GetBValue((int)Eval("ExamType"))%></td>
                                </tr>
                            </ItemTemplate>
                            <FooterTemplate>
                                </table></div>
                            </FooterTemplate>
                        </asp:Repeater>
                     </ContentTemplate>
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="btnBind" EventName="Click" />
                    </Triggers>
                </asp:UpdatePanel>
                <div style="display: none;">
                    <asp:Button ID="btnBind" runat="server" OnClick="btnBind_Click" Text="btnBind" /><asp:TextBox ID="subjectIDtxt" runat="server">0</asp:TextBox>
                    <asp:HiddenField ID="schoolyearTxt" runat="server" Value="" />
                    <asp:HiddenField ID="termTxt" runat="server" Value="" />
                    <asp:HiddenField ID="gradeTxt" runat="server" Value="" />
                </div> 
                <div id="upInputPop" class="layoutWarp" style="display: none; width:600px;height:500px;">
                    <div class="title" >
                        <span id="upInputPopTitle"></span>
                        <a title="关闭" onclick="MyClosePopForm();">关闭</a>
                    </div>
                    <iframe src="" name="ifram" id="parfrm" style="height: 85%;width: 95%;overflow:hidden;" frameborder="0"   ></iframe>
                </div> 
                
                <%-- 添加项目 --%>
                <div id="popTable" class="layoutWarp" style="display: none; width: 400px;">
                    <div class="title">
                        <span id="formTitle">颁奖</span> <a title="关闭" onclick="return CloseMask('popTable')">关闭</a>
                    </div>
                    <div id="proInfo" style="vertical-align:middle; text-align:left; overflow:auto;  height:240px; ">
                        <input id="btnSetAward" type="button" value="确定" onclick="OnSave('popTable')" class="commonBut"/>
                        <div id="areainfo">
                        </div>
                    </div>
                </div>
                
            </div>
        </div>
    </form>
</body>
</html>
<script type="text/javascript">
     OnView();
     SetChange(OnTermChange);
</script>